{extend name="main" /}

{block name="body"}
<div class="layui-card layadmin-header">
    <div class="layui-breadcrumb" lay-filter="breadcrumb" style="visibility: visible;">
        <a href="{:url('index/home',array('webid'=>$web['id']))}">{$web.title}</a>
        <a><cite>{$module.name}</cite></a>
    </div>
</div>
<div class="layui-fluid">
    <div class="layui-card">
        <div class=" layui-card-header layuiadmin-card-header-auto">
            <form class="layui-form" method="get">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <a href="{:url('add',array('webid'=>$web['id'],'moduleid'=>$param['moduleid']))}" class="layui-btn" title="添加">
                            添加
                        </a>
                    </div>
                    <div class="layui-inline">
                        <a href="javascript:;" title="确认要删除吗？" class="layui-btn layui-btn-danger" id="deleteAll">
                            删除
                        </a>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">总计：{$count}</label>
                        <div class="layui-input-inline">
                            <input type="text" name="kw" class="layui-input" value="{$param.kw}">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button class="layui-btn">
                            <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                        </button>
                    </div>
                </div>
            </form>
        </div>
        <div class="layui-card-body">
            <table class="layui-table">
                <tr>
                    <th><b><input type="checkbox" id="selectAll"></b></th>
                    <th><b>ID</b></th>
                    <th><b>标题</b></th>
                    <th><b>栏目</b></th>
                    <th><b>时间</b></th>
                    <th><b>操作</b></th>
                </tr>

                <tbody>
                {foreach name="list" item="vo"}
                <tr>
                    <td><input type="checkbox" name="ids[]" value="{$vo.id}" class="checkids"></td>
                    <td>{$vo.itemid}</td>
                    <td>{$vo.title}</td>
                    <td>{$vo.catname}</td>
                    <td>{:Date('Y-m-d H:i:s',$vo.addtime)}</td>
                    <td>
                        <a href="{:url('edit',array('webid'=>$web['id'],'moduleid'=>$param['moduleid'],'itemid'=>$vo['itemid']))}" class="layui-btn layui-btn-normal layui-btn-xs">
                            <i class="layui-icon layui-icon-edit"></i>编辑
                        </a>
                        <a href="{:Url('delete',array('id'=>$vo['id']))}" title="确认要删除吗？" class="layui-btn layui-btn-danger layui-btn-xs xn_delete">
                            <i class="layui-icon layui-icon-delete"></i>删除
                        </a>
                    </td>
                </tr>
                {/foreach}
                </tbody>
            </table>
        </div>
    </div>
    <div class="pages">
        {$list|raw}
    </div>
</div>
{/block}

{block name="js"}
<script>
    // layui.use('laydate', function(){
    //     var laydate = layui.laydate;

    //     laydate.render({
    //         elem: '#start_date'
    //     });
    //     laydate.render({
    //         elem: '#end_date'
    //     });
    // });

    var form = layui.form;
    form.on('select(position1)', function(res) { 
        $("#position2").empty();
        if(res.value==3){
            $.get("{:url('admin/DataContentChipPosition/getSonPosition')}?pid="+res.value,function(result){
                if(result.status){
                    $("#position2").append(new Option('请选择',0));
                    $.each(result.data,function(index,item){
                        $("#position2").append(new Option(item.sort+'.'+item.title,item.id));
                    });
                    form.render("select");
                }
            });
            $('#pos2').removeClass('layui-hide');
        }else{
            $("#position2").append(new Option('请选择',0));
            form.render("select");
            $('#pos2').addClass('layui-hide');
        }
    })

    $(function() {
        var $selectAll = $("#selectAll");
        $selectAll.click(function() {
            if ($selectAll.prop("checked") == true) {
                $('.checkids').prop("checked", true);
            } else {
                $('.checkids').prop("checked", false);
            }
        });

        $("#deleteAll").click(function(){
            layer.confirm('确认删除选定内容吗?', {icon: 3, title:'操作提示'}, function(index){
                var ids = [];
                $('.checkids:checked').each(function(index,obj){
                    ids.push(obj.value);
                });
                $.get("{:Url('deleteAll')}?ids="+ids,function(data){
                    layer.msg(data.msg, {
                    time: 1000 
                    }, function(){
                    location.reload();
                    }); 
                });
            });
        });
    });
</script>
{/block}